/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package bean;

import business.FlightBusiness;
import business.LocationsBusiness;
import java.util.List;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.RequestScoped;
import model.Flight;
import model.Locations;

/**
 *
 * @author Administrator
 */
@ManagedBean
@RequestScoped
public class MngFlightBean {
    private FlightBusiness flightBusiness = new FlightBusiness();
    private LocationsBusiness locationsBusiness = new LocationsBusiness();
    private Flight flight;
    private List<Locations> listLocation;
    private List<Flight> listFlight ;

    public Flight getFlight() {
        return flight;
    }

    public void setFlight(Flight flight) {
        this.flight = flight;
    }
    
    public List<Locations> getListLocation() {
        return listLocation;
    }

    public void setListLocation(List<Locations> listLocation) {
        this.listLocation = listLocation;
    }

    public List<Flight> getListFlight() {
        return listFlight;
    }

    public void setListFlight(List<Flight> listFlight) {
        this.listFlight = listFlight;
    }

    public String newFlightAction(){
        flightBusiness.newFlight(flight);
        listFlight = flightBusiness.listAllFilght();
        return "managementflight.xhtml";
    }

    public String updateFlightAction(Flight flight){
        flightBusiness.updateFlight(flight);
        listFlight = flightBusiness.listAllFilght();
        return "managementflight.xhtml";
    }
    /** Creates a new instance of MngFlightBean */
    public MngFlightBean() {
        flight = new Flight();
        listFlight = flightBusiness.listAllFilght();
        listLocation = locationsBusiness.listAllLocation();
    }

}
